import { describe, it, expect, jest } from "@jest/globals";
import {
  withExponentialBackoff,
  APIError,
  RETRY_AFTER_HEADER,
} from "./withExponentialBackoff";

describe("withExponentialBackoff", () => {
  it("should return result when apiCall succeeds on first attempt", async () => {
    // Arrange
    const apiCall = jest.fn<() => Promise<string>>().mockResolvedValue("Success");

    // Act
    const result = await withExponentialBackoff(apiCall);

    // Assert
    expect(result).toBe("Success");
    expect(apiCall).toHaveBeenCalledTimes(1);
  });

});
